import {uploadImgOrVoice} from '@/api/settlement/settlement'
import {BASE_URL,TOKEN} from '@/utils/request'



//index:refId,files:被插入数据的object，addFile：即将插入的数据,type:上传的文件的类型
//data：全部数据，用于强制视图数据更新，fileInfo：上传图片属性
export function uploadFile(addFile,fileInfo) {
  var url = "";
  if(typeof addFile == 'object') {
    url = addFile.url;
  }else {
    url = addFile;
  }
  return uni.uploadFile({
      url: BASE_URL + '/file/fileUpload',
      filePath: url,
      name: 'file',
      header:{
        token:TOKEN
      },
      //fileInfo:{type：，duration：}
      //type：4、图片   1、语音   3、车牌
      //duraction：时长
      formData: fileInfo
  });
}



//车辆图片上传
const url = '/file/uploadCarImg'

export function uploadImg(path,type,id) {
  return uni.uploadFile({
    url:BASE_URL + url + '/' + id,
    filePath:path,
    name:'file',
    header:{
      token:TOKEN
    },
    formData:{
      type:type
    }
  })
}
